package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.LocalAttrHelper;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.SafeProductTypicalSetMealAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Component;
import java.util.Set;

@Component
@AttrHandler(SafeProductTypicalSetMealAttrHandler.class)
public class SafeProductTypicalSetMealLinkAttrHandler extends AbstractAttrLinkageHandler<AttrData> {

    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        if(KiteStringUtils.equalsAnyIgnoreCase(inst.getActionType().toString(),"K","M")
            && KiteStringUtils.isNotEmpty(attr.getOriginValue())){
            //如果是业务变更，且选择“E”套餐，则其他信息不可编辑
            if( KiteStringUtils.equals(attr.getValue(), "110007147")) {
                Set<String> keySet = inst.getAttrMap().keySet();
                for (String key : keySet) {
                    LocalAttrHelper.setNotEditable(inst, key);
                }
            }
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }
}
